//请求展开的下一条数据
function nextData(){
    var activeObj = $(".site-email").children('.active');
    //$(".mes-content").html('');
    activeObj.find(".content-list").eq(0).trigger('click');
}

//模拟插入对话消息
function insertMessage(){
    var obj = {
        subject:p.subject,
        list:[
            {
                create_time:com.formatDate(new Date().getTime(),'-',':'),
                is_user:1,
                text_html:p.quill.container.firstChild.innerHTML,
            }
        ]
    }
    var dom = template('inbox-talk',obj);
    var contentObj = $(".mes-content");
    contentObj.append(dom);
    contentObj.animate({scrollTop:contentObj[0].scrollHeight},300);
}


//搜索结果
function searchResult(){
    var val = $("input[name='search']").val();
    if(val){
        app.ajax({
            type:'post',
            url:app.api('/api/ticket/list'),
            data:JSON.stringify({
                type:2,
                businessUnitId:p.business_id,
                keywords:val
            }),
            beforeSend:function(){
                $(".load").removeClass('hide');
            },
            success:function(res){
                if(res.code == 0){
                    var insertBox = $("#search");
                    var tmpTitle = template('inbox-site-email-title', res.data);
                    var tmpContent = template('inbox-site-email', res.data);
                    insertBox.find("[data-name='title-num']").html(tmpTitle);
                    insertBox.find("[data-name='com-check']").html(tmpContent);

                    insertBox.show().siblings(".box-list").hide();
                    insertBox.find("[data-name='menuContent']").show();
                    $("[data-name='iconFanhui']").removeClass('hide')
                }else{
                    $.comMessage({
                        type:'prompt',
                        text:res.message,
                    })
                    $("[data-name='iconFanhui']").trigger('click');
                }
            },
            complete:function(){
                $(".load").addClass('hide');
            }
        });
    }else{
        $.comMessage({
            type:'prompt',
            text:'请填写搜索字段！',
        })
    }
}



//拉取邮件收件箱
$(".icon-get-email").on('click',function(){
    return;
    app.ajax({
        type:'post',
        url:app.api('/api/mail/ownerRobot/' + para.token),
        data:{
            account_id:p.account_id,
            admin_id:para.user.admin_id,
            limit:10
        },
        success:function(res){
            if(res.code == 0){
                $.comMessage({
                    type:'success',
                    text:'收取成功！',
                });
                menuBox();
            }else{
                $.comMessage({
                    type:'warning',
                    text:res.message,
                });
            }
        }
    });
});